home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / falclib2.lzh / WINDOW.S < prev   
Text File  |  1994-08-22  |  5KB  |  201 lines

  1. *
  2. * WINDOW.S
  3. *  (vdilib.i & aeslib.i must be included at the end of the program)
  4. *
  5. *    @createwindow
  6. *
  7. *    Creates a simple gem window. It also initialises the application.
  8. *    The size (xwidth,ywidth) is the workarea of the window.
  9. *
  10. * In    wtype equ %info move full close name
  11. *    xstart,ystart,xwidth,ywidth,windowname(string terminated by 0)
  12. * Out    w_handle,ap_id
  13. *    (destroys a lot)
  14. *
  15. *    @recalcwindow
  16. *     Recalculates the window size.
  17. *    (destroys a lot)
  18. *
  19. *    @moveit
  20. *     Moves the window. May be called at every vm_moved(=28) event.
  21. * In     a0.l=adr to messagebuffer
  22. *    (destroys a lot)
  23. *
  24. *    @drawrsrc
  25. *     Draws the rsrc.
  26. *     This function draw doesn't care about clipping, so you should probably not use it.
  27. * In     a0.l=adr to rsrc
  28. *    (destroys a lot)
  29. *
  30. *    @updatersrc
  31. *     Draws the rsrc. Use this when receiving update events(=20).
  32. *     This function takes care of all clipping.
  33. * In     a0.l=adr to rsrc
  34. *    (destroys a lot)
  35. *
  36. *    @topwindow
  37. *     Activates the window. May be called at every vm_topped(=21) event.
  38. * In     a0.l=adr to messagebuffer
  39. *    (destroys a lot)
  40. *
  41. *    @bottomwindow
  42. *     Bottoms the window if it's mine. May be called at every vm_bottomed(=33) event.
  43. * In     a0.l=adr to messagebuffer 
  44. *    (destroys a lot)
  45. *
  46. *    @button
  47. *     Returns the object number that was clicked on. This function may be called
  48. *     at every mousebutton event.
  49. * In     a0.l=adr. to rsrc
  50. *     (It automatically takes the x and y coordinates from int_out)
  51. * Out     d0.w=object that was pressed or -1.
  52. *    (destroys a lot)
  53. *
  54. *    @loadrsrc
  55. *     Loads a resource file and creates a window containg the object in the
  56. *     file. You don't have to call @createwindow if you use @loadrsrc.
  57. * In     wtype equ %info move full close name
  58. *     windowname(string terminated by 0)
  59. *      a0.l=address to a nul terminated filename
  60. * Out     a0.l=address to the resource data
  61. *     (destroys a lot)
  62. *
  63.  
  64.     include    gemmacro.i
  65.  
  66.  
  67. @createwindow
  68.     appl_init
  69.     move.w    d0,ap_id        store the application id
  70.  
  71.     graf_handle
  72.     move.w    d0,current_handle    Desktop's VDI handle
  73.  
  74. * start by opening a virtual workstation
  75.     lea    intin,a0
  76.     moveq    #10-1,d0        -1 for DBF
  77. .fill    move.w    #1,(a0)+        most params are 1
  78.     dbf    d0,.fill
  79.     move.w    #2,(a0)+        use RC system
  80.  
  81.     v_opnvwk            open it
  82.  
  83. * set the mouse to an arrow
  84.     graf_mouse    #0        arrow please
  85.  
  86.     wind_calc #0,#wtype,xstart,ystart,xwidth,ywidth
  87.     movem.w    int_out+2,d0-d3
  88.     movem.w    d0-d3,xstart
  89.  
  90. * and create the window
  91.     wind_create    #wtype,xstart,ystart,xwidth,ywidth
  92.     move.w    d0,w_handle        save the handle (error checks?)
  93.  
  94. * now set its title
  95.     move.l    #windowname,int_in+4
  96.     wind_set    w_handle,#2    title string
  97.  
  98. * now actually show it by opening
  99.     movem.w    xstart,d0-d3
  100.     wind_open    w_handle,d0,d1,d2,d3
  101.  
  102.     bsr    @recalcwindow
  103.     rts
  104.  
  105.  
  106. * calculate the work area of the window
  107. @recalcwindow
  108.     wind_get    w_handle,#4    get work area
  109.     movem.w    int_out+2,d0-d3
  110.     movem.w    d0-d3,xstart
  111.     rts
  112.  
  113.  
  114. @moveit    
  115.     move.w    6(a0),d0
  116.     cmp.w    w_handle,d0
  117.     bne    .ut            not my window!
  118.     move.w    8(a0),int_in+4        new x pos
  119.     move.w    10(a0),int_in+6        new y pos
  120.     move.w    12(a0),int_in+8        width
  121.     move.w    14(a0),int_in+10    heigth
  122.     wind_set    w_handle,#5
  123.     bsr    @recalcwindow
  124. .ut    rts
  125.  
  126. @drawrsrc    move    xstart,16(a0)
  127.         move    ystart,18(a0)
  128.         objc_draw a0,#0,#10,xstart,ystart,xwidth,ywidth
  129.         rts
  130.  
  131. @button        move    xstart,16(a0)
  132.         move    ystart,18(a0)
  133.         objc_find a0,#0,#10,int_out+2,int_out+4
  134.         move    int_out,d0
  135.         rts
  136.  
  137. @updatersrc    move    xstart,16(a0)
  138.         move    ystart,18(a0)
  139.         move.l    a0,a6
  140.         wind_update #1
  141.         wind_get w_handle,#11
  142.         tst.w    int_out+6
  143.         bne    .next
  144.         tst.w    int_out+8
  145.         beq    .out
  146. .next        objc_draw a6,#0,#10,int_out+2,int_out+4,int_out+6,int_out+8
  147.         wind_get w_handle,#12
  148.         tst.w    int_out+6
  149.         bne    .next
  150.         tst.w    int_out+8
  151.         bne    .next
  152. .out        wind_update #0
  153.         rts
  154.         
  155. @topwindow    
  156.         move.w    6(a0),d0
  157.         cmp.w    w_handle,d0
  158.         bne    .ut            not my window!
  159.         wind_set    w_handle,#10
  160. .ut        rts
  161.  
  162. @bottomwindow
  163.         move.w    6(a0),d0
  164.         cmp.w    w_handle,d0
  165.         bne    .ut            not my window!
  166.         wind_set    w_handle,#25
  167. .ut        rts
  168.  
  169. @exitwindow    wind_close    w_handle
  170.         wind_delete    w_handle
  171.         rts
  172.         
  173. @loadrsrc    rsrc_load a0            load & fix resource
  174.         rsrc_gaddr #0,#0        get adr.
  175.         move.l    addr_out,a0
  176.         move.l    a0,-(sp)
  177.         cmp    #32,18(a0)
  178.         bge    .yok
  179.         move    #32,18(a0)
  180. .yok        move.l    16(a0),xstart        window start position
  181.         move.l    20(a0),xwidth        window size
  182.         bsr    @createwindow
  183.         move.l    (sp)+,a0
  184.         rts
  185.  
  186.  
  187.         
  188.  
  189.  
  190. * these have to remain together
  191. xstart    ds.w 1
  192. ystart    ds.w 1
  193. xwidth    ds.w 1
  194. ywidth    ds.w 1
  195.  
  196. w_handle    ds.w 1
  197. ws_handle    ds.w 1
  198. ap_id        ds.w 1
  199.  
  200.  
  201.